package ead.cs.service.workflow;

import ead.cs.domain.workflow.Status;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class StateMachineHandlerImpl implements StateMachineHandler {

    @Autowired(required = false)
    private List<StateMachine> stateMachineList;

    @Override
    public void execute(Status status, String itemId) {
        for(StateMachine stateMachine : stateMachineList){
            StatusExecutor executor = stateMachine.getExecutor(status);
            if(executor == null){
                continue;
            }
            executor.execute(itemId);
        }
    }
}
